﻿using BZ.Logger;
using NDK.DB;
using NDK.Frm;
//using Lmi3d.GoSdk.Messages;
using NDK.Module.BLL;
//using BoTech.Services;
using NDK.Module.DAL;
using NDK.Motion.BLL;
using NDK.Motion.MachineManager;
using NDK.Motion.MachineResources;
using NDK.Motion.Sys;
using NDK.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using static NDK.Frm.Frm_Main;
using static NDK.Module.BLL.Configuration;

namespace NDK.Module.Model
{

    #region 窗体动画效果相关常量
    public enum WindowsEffect
    {
        AW_SLIDE = 0x40000,//使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时，这个标志就被忽略。    
        AW_ACTIVATE = 0x20000,//激活窗口。在使用了AW_HIDE标志后不要使用这个标志。    
        AW_BLEND = 0x80000,//使用淡出效果。只有当hWnd为顶层窗口的时候才可以使用此标志。    
        AW_HIDE = 0x10000,//隐藏窗口，缺省则显示窗口。(关闭窗口用)    
        AW_CENTER = 0x0010,//若使用了AW_HIDE标志，则使窗口向内重叠；若未使用AW_HIDE标志，则使窗口向外扩展。    
        AW_HOR_POSITIVE = 0x0001,//自左向右显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时，该标志将被忽略。    
        AW_VER_POSITIVE = 0x0004,//自顶向下显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时，该标志将被忽略。    
        AW_HOR_NEGATIVE = 0x0002,//自右向左显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时，该标志将被忽略。    
        AW_VER_NEGATIVE = 0x0008//自下向上显示窗口。该标志可以在滚动动画和滑动动画中使用。当使用AW_CENTER标志时，该标志将被忽略。    
    }
    #endregion

    #region 登陆模式
    public enum LoginMode
    {
        PRODUCTION_MODE = 0,
        ENGINEERING_MODE = 1,
        CPKGRR_MODE = 2
    }
    public enum UserAuthority
    {
        删除用户 = 0,
        添加用户 = 1,
        设置页查看 = 2,
        查看视觉页,
        编辑点位,
        编辑回零,
        添加项目,
        删除项目,
        编辑参数页
    }
    #endregion

    #region Excel输出格式
    public enum SaveDataFormat
    {
        XLS = 0,
        CSV = 1,
        XLSX = 2
    }
    #endregion


    public static class Common
    {
        public static Dictionary<string, string> languageDic = new Dictionary<string, string>();

        public static int PasswordLevel = 0;
        //是否显示软键盘
        public static bool isShowKeyBoard = false;
        //版本信息
        public static string currentVersion = "V1.4.3.220406";

        public static string DatabasePath = Environment.CurrentDirectory + @"\\Config";
        public static string DatabaseName = "test1";

        //------------------------------------------------------------

        //System
        public static Configuration.Language currentLanguage = Language.Chinese;
        public static bool isSelfLockStartButtonPressed = false;//启动和暂停按钮是一个，自锁式

        //指纹锁
        public static string fingerPrintAuthority = "";
        public static string fingerPrintUserName = "";
        public static Dlg_AddUeserUI AddUeserUI = new Dlg_AddUeserUI();
        public static string Authority = ""; //登陆用户的权限
        public static bool b_FPLoginClick = false;
        public static bool b_ModifyROIButtonClick = false;
        public static bool b_SaveROIButtonClick = false;
        //public static BioneFPAPILib.FPAPICtrlClass fp; //初始化指纹锁
        public static bool isFileSetPassCode = false;//是否文件夹已经加密，默认是加密状态
        public static FignerPrintForm FPForm = new FignerPrintForm();
        public static int Id = 0;
        public static bool LogIn_TimeOut = false; //登录超时
        public volatile static UserOptionCheckBFMessage msg = null;

        public static bool OpenDoor = false;
        public static bool ClooseDoor = false;
        public static List<GetCSVParam> ListSafteyDoor = new List<GetCSVParam>();
        public static List<GetCSVParam> ListSafteyLight = new List<GetCSVParam>();

        static bool[] _isSafeDoor = new bool[22];
        public static bool[] isSafeDoor
        {
            get { return _isSafeDoor; }
            set
            {
                for (int i = 0; i < _isSafeDoor.Length; i++)
                {
                    if (_isSafeDoor[i] != value[i])
                    {
                        if (AppendUiLog != null)
                            AppendUiLog.Log($"请检查{ListSafteyDoor[i]} , 安全门被打开!", LogType.Error);
                    }
                }
                _isSafeDoor = value;
            }
        }
        static bool[] _isSafeLight = new bool[5];
        public static bool[] isSafeLight
        {
            get { return _isSafeLight; }
            set
            {
                for (int i = 0; i < _isSafeLight.Length; i++)
                {
                    if (_isSafeLight[i] != value[i])
                    {
                        if (AppendUiLog != null)
                            AppendUiLog.Log($"请检查{ListSafteyLight[i]} , 安全光幕被触发!", LogType.Error);
                    }
                }
                _isSafeLight = value;
            }
        }

        public struct FPUserInfo
        {
            public static string UserName;   //用户名
        }

        //Machine
        public volatile static bool isCardInitialed = false;
        public volatile static bool isVisionModularInitialed = false;
        public volatile static bool isFingerPrintInitialed = false;
        public volatile static bool isLightControlInitialed = false;
        public volatile static bool isLeftLaserInitialed = false;
        public volatile static bool isConnectMesInitialed = false;
        public volatile static bool isConnectAppleInitialed = false;


        //data
        public volatile static string dataSavePath = @"D:\Data\output";
        public volatile static string picSavePath = @"D:\Data\image";
        public volatile static string PDCAPicSavePath = @"\\192.168.10.1\d\TempData\";
        public volatile static string pointCheckEncrypterPath = @"D:\Data\output\temp\点检";

        public static string saveCSVpathName = string.Empty;

        public static int OKCount = 0;
        public static int NGCount = 0;
        public static int NACount = 0;
        public static int ExceptionCount = 0;
        public static int TotalCount = 0;
        public static Task dataThread;

        public static bool Sample_4 = false;//上传macmini，手动标记


        public static bool isAppleUploadFinish = true;

        //Program是否在运行
        public static Stopwatch CT = new Stopwatch();
        public static string ProjectName = "";
        public static string startDate = DateTime.Now.ToString("yyyy-MM-dd");
        public static string startTime = DateTime.Now.ToString("HH:mm:ss");

        public static string logFold = "D:\\Log\\NDKLog";
        public static int clearMachineCount = 0;//清料次数

        //窗体显示情况
        public static bool isSettingFormShow = false;
        public static bool isHomeFormShow = false;
        public static bool isLoginFormshow = false;
        public static bool isParamsSettingDialogShow = false;
        public static bool isStatisticsFromShow = false;
        public static bool isVisionFromshow = false;
        public static bool isAlarmFromshow = false;
        public static bool isLoadOffLine = false;
        //login
        public static string username = "";
        public static string password = "";

        public static DateTime lastDayShiftDataSentTime = DateTime.MinValue; // 记录上一次白班数据发送时间
        public static DateTime lastNightShiftDataSentTime = DateTime.MinValue; // 记录上一次晚班数据发送时间

        #region 机台左侧按钮扫描线程函数：停止、复位、启动

        static bool _status_停止 = false;
        static bool _status_复位 = false;
        static bool _status_启动 = false;
        static bool _status_手自动 = false;
        public static bool status_停止
        {
            get
            {
                return _status_停止;
            }
            set
            {
                if (_status_停止 != value)
                {
                    if (Line == "右")
                        Machine.OmronPLC_Hearb.WriteBool(stCom_0_B_1, value);
                    _status_停止 = value;
                    if (_status_停止)
                        PublicMethod.Pause();
                }
            }
        }
        public static bool status_复位
        {
            get
            {
                return _status_复位;
            }
            set
            {
                if (_status_复位 != value)
                {
                    if (Line == "右")
                        Machine.OmronPLC_Hearb.WriteBool(stCom_0_B_2, value);
                    _status_复位 = value;
                    if (_status_复位)
                        PublicMethod.Intial(false);
                }
            }
        }
        public static bool status_启动
        {
            get
            {
                return _status_启动;
            }
            set
            {
                if (_status_启动 != value)
                {
                    if (Line == "右")
                        Machine.OmronPLC_Hearb.WriteBool(stCom_0_B_0, value);
                    _status_启动 = value;
                    if (_status_启动)
                        PublicMethod.Start();
                }
            }
        }

        static double MotionSpeedPercentage = 0;
        /// <summary>
        /// //有信号是手动,无信号是自动
        /// </summary>
        public static bool status_手自动
        {
            get
            {
                return _status_手自动;
            }
            set
            {
                if (_status_手自动 != value)
                {
                    if (value)
                    {
                        MotionSpeedPercentage = MachineDataManager.Instance.MotionSpeedPercentage;
                        MachineDataManager.Instance.MotionSpeedPercentage = 20;
                    }
                    else
                    {
                        if (MotionSpeedPercentage != 0)
                            MachineDataManager.Instance.MotionSpeedPercentage = MotionSpeedPercentage;
                    }
                    Machine.OmronPLC_Hearb.WriteBool(stCom_0_B_3, value);
                }
                _status_手自动 = value;
                if (value)
                {
                    if (MachineStatusManager.CurrentMachineStatus == MachineStatus.Running && !手动放料)
                    {
                        PublicMethod.Pause();
                        AppendUiLog.Log($"机台运行中,触发手动状态，机台暂停！！！", LogType.Error);
                    }
                }
                else
                {
                    //屏蔽安光幕 = false;
                }
                PublicMethod.ShowText(Frm_Main.Instance.lbl_Loading, _status_手自动 == true ? "手动状态" : "自动状态", _status_手自动 == true ? Color.Red : Color.Green, Color.Black);
            }
        }

        #endregion


        //点检
        public static string pointCheckPath = Environment.CurrentDirectory + "\\Config\\Config";
        public static string SafeFilePath = Environment.CurrentDirectory + "\\Config\\Safe";
        /// <summary>
        /// Block点检标志
        /// </summary>
        public static bool isBlockPointCheck { get; set; } = false;

        public static int NeedBlockCheckCount { set; get; } = 0;
        public static bool _IsNeedBlockCheck = false;
        public static bool IsNeedBlockCheck
        {
            set
            {
                _IsNeedBlockCheck = value;
            }
            get
            {
                return _IsNeedBlockCheck;
            }
        }
        public static bool DayBlockCheckRun { set { INIUtils.Write("点检", "白班点检", value.ToString(), ProTypeIniPath); } get { return Convert.ToBoolean(INIUtils.Read("点检", "白班点检", ProTypeIniPath)); } }
        public static bool NightBlockCheckRun { set { INIUtils.Write("点检", "夜班点检", value.ToString(), ProTypeIniPath); } get { return Convert.ToBoolean(INIUtils.Read("点检", "夜班点检", ProTypeIniPath)); } }

        static List<bool> BlockCheckBools = new List<bool>() { false, false, false, false };
        static bool _BlockCheck1 = false;
        public static bool BlockCheck1
        {
            set { INIUtils.Write("点检", "点检1", value.ToString(), ProTypeIniPath); }
            get
            {
                bool status = Convert.ToBoolean(INIUtils.Read("点检", "点检1", ProTypeIniPath));
                if (status != _BlockCheck1 || !BlockCheckBools[0])
                {
                    BlockCheckBools[0] = true;
                    _BlockCheck1 = status;
                    PublicMethod.ShowText(Frm_Main.Instance.lbBlockCheck1, "点检1", status == true ? Color.Green : Color.Red, Color.Black);
                }
                return status;
            }
        }
        static bool _BlockCheck2 = false;
        public static bool BlockCheck2
        {
            set { INIUtils.Write("点检", "点检2", value.ToString(), ProTypeIniPath); }
            get
            {
                bool status = Convert.ToBoolean(INIUtils.Read("点检", "点检2", ProTypeIniPath));
                if (status != _BlockCheck2 || !BlockCheckBools[1])
                {
                    BlockCheckBools[1] = true;
                    _BlockCheck2 = status;
                    PublicMethod.ShowText(Frm_Main.Instance.lbBlockCheck2, "点检2", status == true ? Color.Green : Color.Red, Color.Black);
                }
                return status;
            }
        }


        public static string 白班点检时间 = DateTime.Now.ToString("HH:mm:ss");
        public static string 夜班点检时间 = DateTime.Now.ToString("HH:mm:ss");


        /// <summary>
        /// 产品点检标志
        /// </summary>
        public static bool isProductPointCheck { get; set; } = false;
        public static bool isLinearPointCheck = false;//线性点检标志 默认开启 真实测block数据关闭

        public static int ProductType = -1;//-1正常产品    大中小   3  2  1
        public static int ProductTypeRight = -1;//-1正常产品    大中小   3  2  1


        public static DataTable pointCheckTable = null;//Block点检表
        public static DataTable GRRPointCheckTable = null;//Product点检表
        public static DataTable GRRRangeTable = null;//Product点检表
        public static DataTable AlarmPLCInfo = null;//报警信息

        public static List<string> FAIListError = new List<string>();
        public static List<string> FAIListErrorLeft = new List<string>();
        public static List<string> FAIListErrorRight = new List<string>();
        public static int PPGCountNG { get; set; } = 0;

        public static int MacMiniTimeOut { set; get; } = 0;
        public static int MacMiniDataCount { set; get; } = 0;

        //算子所在路径
        public static string ProcedurePath = "";

        //swd上传Mes
        public static string MesJession = "";
        public static string MesTestId = "";
        public static string MesUrl = "";

        public static string MesDcGroup = "";
        public static bool UploadMESFail = false; //上传MES失败
        public static string siteId = "";

        //测量项等参数
        public static List<List<MeasureSize>> ListmeasureSizeListPosition = new List<List<MeasureSize>>();



        //抽检采样
        public static Random r_Sample = new Random();//抽样
        public static List<string> SampleSN = new List<string>();//是否是抽样产品
        public static bool isSample = false;//是否开启采样
        public static int sampleCount = 0;//总样总数
        public static int samplePersent = 0;//抽样概率
        public static int curSampleCount = 0;//已经抽样个数
        public static int curMeasureId = 0;//总样本数
        public static List<int> sampleIndexList = new List<int>();


        public static bool ClearModel;

        public static string leftResult = "";
        public static string rightResult = "";

        public static BZLogger AppendUiLog;

        public static string CtLook = "0.00";

        public static bool 启动一次
        {
            get; set;
        } = false;
        /// <summary>
        /// 强制ok
        /// </summary>
        public static bool isForceOK { get; set; } = false;
        /// <summary>
        /// 强制ng
        /// </summary>
        public static bool isForceNG { get; set; } = false;
        /// <summary>
        /// 强制抽检
        /// </summary>
        public static bool isForceORT { get; set; } = false;

        public static bool isAutoLoadPuting = false;//自动上料工站正在放料


        public volatile static List<Axis> CurentStationAxes = new List<Axis>();//当前工站对应的轴


        public static string RedisUrl = "192.168.10.3:6379";

        public static PrjPara pPrjPara;

        public static Stopwatch s11 = new Stopwatch();

        #region 数据库定义
        public delegate void delegateUpdateStartOnce(bool? 启动一次, string msg = "");
        public delegate void delegateUpdatePLC(string msg);


        #region Int类型
        public static int 气缸等待时间 = 3000;
        public static int PPG保压时间 = 2000;
        static int _GRR循环次数 = 9;
        public static int GRR循环次数
        {
            get { return _GRR循环次数; }
            set
            {
                _GRR循环次数 = value;
            }
        }
        public static int 光源打开延时 = 100;
        public static int BarcodeLength = 0;
        public static int 相同通道NG片数 = 3;
        public static int 不同通道NG片数 = 3;
        public static int MacMini卡前站NG片数 = 3;
        public static int MacMini数据上传超时NG片数 = 5;
        public static int PPG异物NG片数 = 3;
        public static int 掉料报警延时 = 50;
        public static int PPGCount = 0;
        //保留报警信息的天数
        public static int SaveDaysOfAlarmInfo = 100;
        #endregion
        #region double类型
        public static double PPGOffset = 0;
        public static double 偏移量X_A = 0;
        public static double 偏移量Y_A = 0;
        public static double 偏移量R_A = 0;

        public static double 偏移量X_B = 0;
        public static double 偏移量Y_B = 0;
        public static double 偏移量R_B = 0;

        public static double PosionExp = 0;


        public static double PPGTotal_L = 0;
        public static double PPGTotal_R = 0;
        public static List<double> PPG_L = new List<double>();
        public static List<double> PPG_R = new List<double>();
        #endregion
        #region string类型
        public static string PLC_IP = "";
        public static string ATL_PLC_IP = "127.0.0.1";
        public static string ATL_PLC_Port = "9601";
        public static string ATL_Mes_Port = "9601";
        public static string PPGIP = "";
        public static string SNIP = "";
        public static string ComputerIP = "";
        public static string ComputerPort = "";
        public static string PPGName = "";
        public static string SLP_Path = "D:\\NDK-Software\\SLP\\ACMT_4080.slp";
        public static string Line = "左";
        public static string strNameImagePath = "D:\\下激光图片勿删";
        public static string HOSTNAME;
        public static string Line_No;
        public static string ConsumerAdress = "ATL";
        public static string 短边长度1_1 = "0,100";
        public static string 短边长度2_1 = "0,100";
        public static string 短边长度3_1 = "0,100";
        public static string 短边长度4_1 = "0,100";
        public static string 短边长度3_2 = "0,100";
        public static string 短边长度4_2 = "0,100";
        public static string 长边长度1_1 = "0,100";
        public static string 长边长度2_1 = "0,100";
        public static string 长边长度3_1 = "0,100";
        public static string 长边长度4_1 = "0,100";
        public static string 长边长度3_2 = "0,100";
        public static string 长边长度1_2 = "0,100";
        public static string 长边长度4_2 = "0,100";
        public static string 上激光长度1_1 = "100,200";

        public static string 治具1上CCD光源1名称 = "上CCD光源1_1";
        public static string 治具1上CCD光源2名称 = "上CCD光源1_2";
        public static string 治具1上CCD光源3名称 = "上CCD光源1_3";
        public static string 治具1上CCD光源4名称 = "上CCD光源1_4";
        public static string 治具2上CCD光源1名称 = "上CCD光源2_1";
        public static string 治具2上CCD光源2名称 = "上CCD光源2_2";
        public static string 治具2上CCD光源3名称 = "上CCD光源2_3";
        public static string 治具2上CCD光源4名称 = "上CCD光源2_4";
        #endregion
        #region bool类型
        public static bool 屏蔽安全门 = false;
        public static bool 屏蔽安光幕 = false;
        public static bool 屏蔽蜂鸣器 = false;

        static bool _屏蔽1号载具 = false;
        public static bool 屏蔽1号载具
        {
            get { return _屏蔽1号载具; }
            set
            {
                _屏蔽1号载具 = value;
            }
        }
        static bool _屏蔽2号载具 = false;
        public static bool 屏蔽2号载具
        {
            get { return _屏蔽2号载具; }
            set
            {
                _屏蔽2号载具 = value;
            }
        }

        public static VehiclesSelectType VehiclesSelect { get; set; } = VehiclesSelectType.待复位后看状态;

        public enum VehiclesSelectType
        {
            双载具运行,
            一号载具运行,
            二号载具运行,
            停止运行,
            待复位后看状态
        }

        static bool _屏蔽联机PLC = false;
        public static bool 屏蔽联机PLC
        {
            get { return _屏蔽联机PLC; }
            set
            {
                _屏蔽联机PLC = value;
                Machine.OmronPLC_Up.WriteBool(stCom_0_OnLine, _屏蔽联机PLC);
            }
        }

        public static bool 屏蔽PPG = false;
        public static bool 屏蔽真空检测 = false;
        public static bool 屏蔽Mes上传 = false;
        public static bool 屏蔽Apple上传 = false;
        public static bool 屏蔽扫码 = false;
        static bool _手动放料 = false;
        public static bool 手动放料
        {
            get { return _手动放料; }
            set
            {
                if (_手动放料 != value)
                {
                    PublicMethod.Stop();
                    if (AppendUiLog != null)
                        AppendUiLog.Log($"手动放料模式变换,安全起见,停机初始化再运行", LogType.Error);
                }
                _手动放料 = value;
                PublicMethod.ShowText(Frm_Main.Instance.lbHandStatus, _手动放料 == true ? "手动放料启用中" : "手动放料关闭", _手动放料 == true ? Color.Green : Color.White, Color.Black);
            }
        }
        public static bool IsSaveImage = false;
        public static bool IsSaveOriginalImageOK = false;
        public static bool IsSaveOriginalImageNG = false;
        public static bool IsSaveScreenshotImageOK = false;
        public static bool IsSaveScreenshotImageNG = false;
        public static bool isWriteLog = false;
        public static bool 保存定位图片 = false;

        public static bool _屏蔽点检 = false;
        public static bool 屏蔽点检
        {
            get { return _屏蔽点检; }
            set
            {
                if (_屏蔽点检 != value)
                    NeedBlockCheckCount = 0;
                _屏蔽点检 = value;
            }
        }
        #endregion

        //Mes上传信息
        public static string 服务器地址 = "http://10.12.1.35:8004/produce/stationCheckAPI/getInfo";
        public static string 当前工站 = "APMT_POST";
        public static string 产品型号 = "18S2068";
        public static string 工位信息 = "ATEGG";
        public static string 设备电脑名 = "DS-PC1";

        public static int whichBlock = -1;

        #region 上传苹果MacMini连接服务器定义变量
        public static AsyncTcpIpUtils.ClientAsync AsyncClient_MacMini = new AsyncTcpIpUtils.ClientAsync();  //连接自身通讯软件
        public static string AsyncRcvMsgFromMacMini;  //接收到的信息
        public static string strKey_MacMini;

        public static JUDGEMENT_RESULT rtnDataResult_Vision = JUDGEMENT_RESULT.OK; //视觉算法数据判定结果
        public static JUDGEMENT_RESULT rtnDataResult_PPG = JUDGEMENT_RESULT.OK; //PPG数据判定结果

        public static bool b硬件初始化成功 = false;

        public static List<CameraModel> CameraParams = new List<CameraModel>();
        #endregion
        #endregion


        public static Action<List<ProductTypeMeasureItemEnable>> UpdateMeasureItemsEnable = null;
        public static string ProTypeIniPath = Application.StartupPath + @"\Config\ProductType.ini";
        public static string ProTypeCsvPath = Application.StartupPath + @"\Config\ProductType.csv";
        static string _CurProType = string.Empty;
        public static string CurProType
        {
            get { return _CurProType; }
            set
            {
                if (_CurProType != value)
                {
                    _CurProType = value;
                    MeasureSizeServices measureSizeService = new MeasureSizeServices();
                    ListmeasureSizeListPosition = new List<List<MeasureSize>>();
                    for (int i = 0; i < 4; i++)
                        ListmeasureSizeListPosition.Add(measureSizeService.GetAllByProjectNameAndTurnNum(_CurProType, i + 1));

                    MySQLDBHelper.DataBaseIni("AIM_" + DateTime.Now.ToString("yyyyMMdd"), ListmeasureSizeListPosition[0]);
                }
            }
        }
        public const string Section_ProductTypeConfig = "ProductTypeConfig";
        public const string Section_MeasureItems = "MeasureItems";
        public static List<string> DefaultMeasureItems = new List<string>();
        public static List<ProductTypeMeasureItemEnable> ProductTypeMeasureItemEnableList = new List<ProductTypeMeasureItemEnable>();
        public static ProductTypeMeasureItemEnable CurProTypeMeasureItems = new ProductTypeMeasureItemEnable();

        #region PLC 交互信号地址
        /// <summary>
        /// PLC请求定位拍照
        /// </summary>
        public static string stModule_0_PLC_PC_B_0 = "stModule[0].PLC_PC.B[0]";
        /// <summary>
        /// PPLC给PC的九点标定次数
        /// </summary>
        public static string stCom_0_W_0 = "stCom[0].W[0]";
        /// <summary>
        /// PLC给PC 标定机械手X坐标 Real
        /// </summary>
        public static string stCom_0_PLC_PC_CCD_X = "stCom[0].PLC_PC.CCD_X";
        /// <summary>
        /// PLC给PC 标定机械手Y坐标 Real
        /// </summary>
        public static string stCom_0_PLC_PC_CCD_Y = "stCom[0].PLC_PC.CCD_Y";
        /// <summary>
        /// PLC给PC 标定机械手R坐标 Real
        /// </summary>
        public static string stCom_0_PLC_PC_CCD_R = "stCom[0].PLC_PC.CCD_R";
        /// <summary>
        /// 上料—A侧下料到位
        /// </summary>
        public static string stCom_0_PLC_PC_UldInPos = "stCom[0].PLC_PC.UldInPos";
        /// <summary>
        /// 上料—A侧交互完成（破真空，并抬起)
        /// </summary>
        public static string stCom_0_PLC_PC_UldCompAck = "stCom[0].PLC_PC.UldCompAck";
        /// <summary>
        /// 上料—A侧产品信息
        /// </summary>
        public static string stCom_0_PLC_PC_PanelID1 = "stCom[0].PLC_PC.PanelID1";
        /// <summary>
        /// 上料—B侧下料到位
        /// </summary>
        public static string stCom_1_PLC_PC_UldInPos = "stCom[1].PLC_PC.UldInPos";
        /// <summary>
        /// 上料—B侧交互完成（破真空，并抬起)
        /// </summary>
        public static string stCom_1_PLC_PC_UldCompAck = "stCom[1].PLC_PC.UldCompAck";
        /// <summary>
        /// 上料—B侧产品信息
        /// </summary>
        public static string stCom_1_PLC_PC_PanelID1 = "stCom[1].PLC_PC.PanelID1";

        /// <summary>
        /// 下料—A侧下料到位
        /// </summary>
        public static string stCom_2_PLC_PC_LdInPos = "stCom[2].PLC_PC.LdInPos";
        /// <summary>
        /// 下料—A侧交互完成（破真空，并抬起)
        /// </summary>
        public static string stCom_2_PLC_PC_LdCompAck = "stCom[2].PLC_PC.LdCompAck";
        /// <summary>
        /// 下料—B侧下料到位
        /// </summary>
        public static string stCom_3_PLC_PC_LdInPos = "stCom[3].PLC_PC.LdInPos";
        /// <summary>
        /// 下料—B侧交互完成（破真空，并抬起)
        /// </summary>
        public static string stCom_3_PLC_PC_LdCompAck = "stCom[3].PLC_PC.LdCompAck";
        /// <summary>
        /// 上料—A侧PLC给PC的安全信号
        /// </summary>
        public static string stCom_0_PLC_PC_Safety = "stCom[0].PLC_PC.Saftey";
        /// <summary>
        /// 上料—B侧PLC给PC的安全信号
        /// </summary>
        public static string stCom_1_PLC_PC_Safety = "stCom[1].PLC_PC.Saftey";
        /// <summary>
        /// 下料—A侧PLC给PC的安全信号
        /// </summary>
        public static string stCom_2_PLC_PC_Safety = "stCom[2].PLC_PC.Saftey";
        /// <summary>
        /// 下料—B侧PLC给PC的安全信号
        /// </summary>
        public static string stCom_3_PLC_PC_Safety = "stCom[3].PLC_PC.Saftey";

        /// <summary>
        /// PLC给PC心跳
        /// </summary>
        public static string stCom_0_PLC_PC_Heartbeat = "stCom[0].PLC_PC.Heartbeat";
        /// <summary>
        /// PLC给PC的通讯类提示报警
        /// </summary>
        public static string stCom_0_PLC_PC_B_0 = "stCom[0].PLC_PC.B[0]";
        /// <summary>
        /// PLC给PC的重报警
        /// </summary>
        public static string stCom_0_PLC_PC_B_1 = "stCom[0].PLC_PC.B[1]";
        /// <summary>
        /// PLC给PC的轻报警
        /// </summary>
        public static string stCom_0_PLC_PC_B_2 = "stCom[0].PLC_PC.B[2]";
        /// <summary>
        /// PLC给PC的安全门打开
        /// </summary>
        public static string stCom_0_PLC_PC_B_3 = "stCom[0].PLC_PC.B[3]";
        /// <summary>
        /// PLC给PC的安全光幕被遮挡
        /// </summary>
        public static string stCom_0_PLC_PC_B_4 = "stCom[0].PLC_PC.B[4]";
        /// <summary>
        /// A侧屏蔽
        /// </summary>
        public static string stCom_2_PLC_PC_B_0 = "stCom[2].PLC_PC.B[0]";
        /// <summary>
        /// A侧清料
        /// </summary>
        public static string stCom_2_PLC_PC_B_1 = "stCom[2].PLC_PC.B[1]";
        /// <summary>
        /// B侧屏蔽
        /// </summary>
        public static string stCom_3_PLC_PC_B_0 = "stCom[3].PLC_PC.B[0]";
        /// <summary>
        /// B侧清料
        /// </summary>
        public static string stCom_3_PLC_PC_B_1 = "stCom[3].PLC_PC.B[1]";




        /// <summary>
        /// PC定位拍照完成
        /// </summary>
        public static string stModule_0_PC_PLC_B_0 = "stModule[0].PC_PLC.B[0]";
        /// <summary>
        /// 两个产品的补偿值[0..5]
        /// </summary>
        public static string wLdBeltPdt_OFFSET = "wLdBeltPdt_OFFSET";

        /// <summary>
        /// 上料—A侧请求上料
        /// </summary>
        public static string stCom_0_PC_PLC_LdReq = "stCom[0].PC_PLC.LdReq";
        /// <summary>
        /// 上料—A侧取料完成（真空吸附OK）
        /// </summary>
        public static string stCom_0_PC_PLC_LdComp = "stCom[0].PC_PLC.LdComp";
        /// <summary>
        /// 上料—B侧请求上料
        /// </summary>
        public static string stCom_1_PC_PLC_LdReq = "stCom[1].PC_PLC.LdReq";
        /// <summary>
        /// 上料—B侧取料完成（真空吸附OK）
        /// </summary>
        public static string stCom_1_PC_PLC_LdComp = "stCom[1].PC_PLC.LdComp";

        /// <summary>
        /// 下料—A侧请求下来
        /// </summary>
        public static string stCom_2_PC_PLC_UldReq = "stCom[2].PC_PLC.UldReq";
        /// <summary>
        /// 下料—A侧下料完成（破真空完成）
        /// </summary>
        public static string stCom_2_PC_PLC_UldComp = "stCom[2].PC_PLC.UldComp";
        /// <summary>
        /// 下料—A侧产品信息
        /// </summary>
        public static string stCom_2_PC_PLC_PanelID1 = "stCom[2].PC_PLC.PanelID1";
        /// <summary>
        /// 下料—A侧产品结果
        /// </summary>
        public static string stCom_2_PC_PLC_PanelStatus = "stCom[2].PC_PLC.PanelStatus1";
        /// <summary>
        /// 下料—B侧请求下来
        /// </summary>
        public static string stCom_3_PC_PLC_UldReq = "stCom[3].PC_PLC.UldReq";
        /// <summary>
        /// 下料—B侧下料完成（破真空完成）
        /// </summary>
        public static string stCom_3_PC_PLC_UldComp = "stCom[3].PC_PLC.UldComp";
        /// <summary>
        /// 下料—B侧产品信息
        /// </summary>
        public static string stCom_3_PC_PLC_PanelID1 = "stCom[3].PC_PLC.PanelID1";
        /// <summary>
        /// 下料—B侧产品结果
        /// </summary>
        public static string stCom_3_PC_PLC_PanelStatus = "stCom[3].PC_PLC.PanelStatus1";
        /// <summary>
        /// A侧PC反馈清料完成
        /// </summary>
        public static string stCom_2_PC_PLC_B_0 = "stCom[2].PC_PLC.B[0]";
        /// <summary>
        /// B侧PC反馈清料完成
        /// </summary>
        public static string stCom_3_PC_PLC_B_0 = "stCom[3].PC_PLC.B[0]";

        /// <summary>
        /// PC远程控制PLC信号
        /// </summary>
        public static string stCom_0_OnLine = "stCom[0].OnLine";
        /// <summary>
        /// PC-PLC启动
        /// </summary>
        public static string stCom_0_B_0 = "stCom[0].B[0]";
        /// <summary>
        /// PC-PLC停止
        /// </summary>
        public static string stCom_0_B_1 = "stCom[0].B[1]";
        /// <summary>
        /// PC-PLC复位
        /// </summary>
        public static string stCom_0_B_2 = "stCom[0].B[2]";
        /// <summary>
        /// PC-PLC手自动模式
        /// </summary>
        public static string stCom_0_B_3 = "stCom[0].B[3]";
        /// <summary>
        /// PC-PLCGRR模式
        /// </summary>
        public static string stCom_0_B_4 = "stCom[0].B[4]";
        /// <summary>
        /// PC-PLC清料模式
        /// </summary>
        public static string stCom_0_B_5 = "stCom[0].B[5]";
        /// <summary>
        /// PC-PLC点检模式
        /// </summary>
        public static string stCom_0_B_6 = "stCom[0].B[6]";
        #endregion
    }


    public class ProductTypeMeasureItemEnable
    {
        public string ProductType { get; set; }

        public Dictionary<string, bool> MeasureItemEnableDic { get; set; }

        public ProductTypeMeasureItemEnable()
        {
            ProductType = "";
            MeasureItemEnableDic = new Dictionary<string, bool>();
        }
    }

    public class GUIEventArgs : EventArgs
    {
        public int Index
        {
            get; set;
        }

        public GUIEventArgs(int msg)
        {
            Index = msg;
        }
    }

}
